Geographical Analysis of media

5. Widgets who what when where

Author

Claude Grasland

Objective

The aim of this section is to present the different widgets used for the exploration of hypercubes and developped during the ODYCCEUS project. We adapt a little the initial programs for the case of octocubes that are used in IMAGEUN but the principles remains the same. Each widget will export a dataframe and a plotly figure, making possible to store the results in javascript and/or to use the table for development with another software.

Preparation

Load multilevel octocubes and transform in hypercubes

We load the octocubes at different levels of time agregation and transform them in hypercubes by removing the dual dimensions of states and regions. But we keep the order dimenson in order to be able to select only titles without description.

base<-readRDS("hypercubes/hc_mycorpus_covid_states_regions_multilevel.RDS")
hc_day<-base$day[,.(tag=sum(tags),news=sum(news)),.(order,who,what,when,states=states1,regions=regions1)]
hc_week<-base$week[,.(tag=sum(tags),news=sum(news)),.(order,who,what,when,states=states1,regions=regions1)]
hc_month<-base$month[,.(tag=sum(tags),news=sum(news)),.(order,who,what,when,states=states1,regions=regions1)]
hc_quarter<-base$quarter[,.(tag=sum(tags),news=sum(news)),.(order,who,what,when,states=states1,regions=regions1)]
hc_year<-base$year[,.(tag=sum(tags),news=sum(news)),.(order,who,what,when,states=states1,regions=regions1)]

Load statistical test function

#### ---------------- testchi2 ----------------
#' @title  Compute the average salience of the topic and test significance of deviation
#' @name what
#' @description create a table and graphic of the topic
#' @param tabtest a table with variable trial, success and null.value
#' @param minsamp : Threshold of sample size requested for salience computation
#' @param mintest : Threshold of estimated value requested for chi-square test


testchi2<-function(tabtest=tabtest,
                   minsamp = 20,
                   mintest = 5) 
{
  tab<-tabtest
  n<-dim(tab)[1]
  
  # Compute salience if sample size sufficient (default : N>20)
  tab$estimate <-NA
  tab$salience <-NA
  tab$chi2<-NA
  tab$p.value<-NA
   tab$estimate<-round(tab$success/tab$trial,5)
   tab$salience<-tab$estimate/tab$null.value
  
  # Chi-square test if estimated value sufficient (default : Nij* > 5)
  
  for (i in 1:n) {
    if(tab$trial[i]*tab$null.value[i]>=mintest) {  
      test<-prop.test(x=tab$success[i],n=tab$trial[i], p=tab$null.value[i], 
                      alternative = "greater")
      tab$chi2[i]<-round(test$statistic,2)
      tab$p.value[i]<-round(test$p.value,5)
    } 
  }
 # }
  return(tab)
}

What

Function

### ---------------- what ----------------
#' @title  Compute the average salience of the topic
#' @name what
#' @description create a table and graphic of the topic
#' @param hc an hypercube prepared as data.table
#' @param subtop a subtag of the main tag (default = NA)
#' @param title Title of the graphic


what <- function (hc = hypercube,
                  what = "what",
                  subtop = NA,
                  title = "What ?")
{
 
  
tab<-hc
tab$what<-tab[[what]]
if (is.na(subtop)){tab$what <-tab$what !="_no_"}else {tab$what <- tab$what == subtop}

tab<-tab[,list(news = sum(news)),by = what]
tab$pct<-100*tab$news/sum(tab$news)

p <- plot_ly(tab,
             labels = ~what,
             values = ~pct,
             type = 'pie') %>%
  layout(title = title,
         xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
         yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))

output<-list("table" = tab, "plotly" =p)

return(output)

}

Application 1 : covid topic

res<-what(hc_year)
res$table
FALSE     what    news       pct
FALSE 1: FALSE 3110692 98.261071
FALSE 2:  TRUE   55050  1.738929
res$plotly

Application n°2 : state subtopic

res <-hc_year %>% filter(states != "_no_") %>%
what(what = "states",
     subtop ="UKR",
     title = "Share of Ukraine in international news")
res$table
FALSE     what      news       pct
FALSE 1: FALSE 599035.74 97.568862
FALSE 2:  TRUE  14926.26  2.431138
res$plotly

Application n°3 : macroregion subtopic

res <-hc_year %>% filter(regions != "_no_") %>%
what(what = "regions",
     subtop ="OR_EU",
     title = "Share of EU in macroregional news")
res$table
FALSE     what     news      pct
FALSE 1: FALSE 56153.67 69.34606
FALSE 2:  TRUE 24822.33 30.65394
res$plotly

Who.What

function

#### ---------------- who.what ----------------
#' @title  visualize variation of the topic between media
#' @name who.what
#' @description create a table of variation of the topic by media
#' @param hc an hypercube prepared as data.table
#' @param test : visualize test (TRUE) or salience (FALSE)
#' @param minsamp : Threshold of sample size requested for salience computation
#' @param mintest sample size of estimate for chi-square test (default = 5)
#' @param title Title of the graphic


who.what <- function (hc = hypercube,
                      what = "what",
                      subtop = NA,
                      test = FALSE,
                      minsamp = 20,
                      mintest = 5,
                      title = "Who says What ?")
{
  
  tab<-hc
  tab$what<-tab[[what]]
if (is.na(subtop)){tab$what <-tab$what !="_no_"}else {tab$what <- tab$what == subtop}
#  {tab$what <-tab$what !="_no_"}
  
  tab<-tab[,list(trial = sum(news),success=round(sum(news*what),0)),by = list(who)]
  ref <-round(sum(tab$success)/sum(tab$trial),4)
  tab$null.value<-ref
  
  tab<-testchi2(tabtest=tab,
                minsamp = minsamp,
                mintest = mintest)
  
  
  
  if (test==FALSE) {tab$index =tab$salience
  tab$index[tab$index>4]<-4
  tab<-tab[tab$trial > minsamp,]
  mycol<-brewer.pal(7,"YlOrRd")
  } 
  else {tab$index=1-tab$p.value
  tab<-tab[tab$trial*tab$null.value>mintest,]
  mycol<-rev(brewer.pal(7,"RdYlBu"))
  mycol[4]<-"lightyellow"
  }
  
  p <- plot_ly(tab,
               x = ~who,
               y = ~estimate*100,
               color= ~index,
               colors= mycol,
               hovertemplate = ~paste('Source: ',who,
                             '<br /> Total news  : ', round(trial,0),
                             '<br /> Topic news : ', round(success,0),
                             '<br /> % observed  : ', round(estimate*100,2),'%',
                             '<br /> % estimated : ', round(null.value*100,2),'%',
                             '<br /> Salience : ', round(salience,2),  
                             '<br /> p.value : ', round(p.value,4)),
               type = "bar")  %>%
    layout(title = title,
           yaxis = list(title = "% news"),
           barmode = 'stack')
  
  output<-list("table" = tab, "plotly" =p)
  
  return(output)
  
}

Applicaton n°1 : Covid Topic

An example of computation of the share of a non spatial topic (Covid) in the full sample of news during the years 2020 and 2021

res <- hc_year %>% 
       filter(when >= as.Date("2020-01-01"), when <=as.Date("2021-12-31")) %>%
 who.what( what = "what",
           title = "Share of Covid in total news (2020-2021)",
           test=TRUE)

res$table
FALSE           who  trial success null.value estimate  salience    chi2 p.value
FALSE 1: DEU_suddeu 116917    9997     0.0931  0.08551 0.9184748   79.79       1
FALSE 2: FRA_figaro 161430   14457     0.0931  0.08956 0.9619764   23.97       1
FALSE 3: TUN_afrman  51195    8387     0.0931  0.16382 1.7596133 3032.07       0
FALSE 4:  TUR_dunya 187927   15350     0.0931  0.08168 0.8773362  290.11       1
FALSE    index
FALSE 1:     0
FALSE 2:     0
FALSE 3:     1
FALSE 4:     0
res$plotly
  • Comment : The share of news where the covid topic is present is significantly higher in the African Manager (16.4%) as compared to the three other newspapers 8 to 9%) .

Application n°2 : State subtopic

An example of computation of the share of a national subtopic (Ukraine) in the sample of news where the topic is present (news with at least one state mentionned) since January 2021

res <-hc_year %>% filter(states != "_no_") %>%
                filter(when >= as.Date("2022-01-01")) %>%

who.what(what = "states",
     subtop ="UKR",
     title = "Share of Ukraine in international news 2022-2023",
     test=TRUE)
res$table
FALSE           who trial success null.value estimate  salience    chi2 p.value index
FALSE 1: DEU_suddeu 10562    2763     0.1112  0.26160 2.3525180 2415.73       0     1
FALSE 2: FRA_figaro 17540    2206     0.1112  0.12577 1.1310252   37.52       0     1
FALSE 3: TUN_afrman 11778     754     0.1112  0.06402 0.5757194  264.81       1     0
FALSE 4:  TUR_dunya 25508    1549     0.1112  0.06073 0.5461331  657.00       1     0
res$plotly
  • Comment : The share of international news where the Ukraine topic is present is significantly higher in the Süddeutche Zeitung (26.2%) and to a lesser extent in Le Figaro (12.6%) as compared to the level observed in the two other newspapers 6 to 7%) .

Application n°3 : Macroregion subtopic

Same example applied to macroregion : what is the share of the subtopic European Union in the subsample news where at least one macroregion is mentionned for the whole period 2013-2023

res <-hc_year %>% filter(regions != "_no_") %>%
who.what(what = "regions",
     subtop ="OR_EU",
     title = "Share of EU in macroregional news (2013-2023)",
     test=TRUE)
res$table
FALSE           who trial success null.value estimate  salience    chi2 p.value index
FALSE 1: DEU_suddeu 18810    8939     0.3065  0.47523 1.5505057 2518.48       0     1
FALSE 2: FRA_figaro 29793    7975     0.3065  0.26768 0.8733442  211.04       1     0
FALSE 3: TUN_afrman  7160    1630     0.3065  0.22765 0.7427406  209.04       1     0
FALSE 4:  TUR_dunya 25213    6278     0.3065  0.24900 0.8123980  391.93       1     0
res$plotly
  • Comment : The share of macroregional news where European Union is mentionned is significantly higher in Süddeutsche Zeitung (47.5%) as compared to the three other newspapers (22 to 27%)

When.What

function

#### ---------------- when.what ----------------
#' @title  visualize variation of the topic through time
#' @name when.what
#' @description create a table of variation of the topic by media
#' @param test : visualize test (TRUE) or salience (FALSE)
#' @param minsamp : Threshold of sample size requested for salience computation
#' @param mintest sample size of estimate for chi-square test (default = 5)
#' @param title Title of the graphic


when.what <- function (hc = hypercube,
                       what = "what",
                       subtop = NA,
                       test = FALSE,
                       minsamp = 20,
                       mintest = 5,
                       title = "When is said What ?")
{
  
  tab<-hc
  tab$what<-tab[[what]]
if (is.na(subtop)){tab$what <-tab$what !="_no_"}else {tab$what <- tab$what == subtop}
#  {tab$what <-tab$what !="_no_"}
  
  tab<-tab[,list(trial = sum(news),success=round(sum(news*what),0)),by = list(when)]
  ref <-round(sum(tab$success)/sum(tab$trial),4)
  tab$null.value<-ref
  
  tab<-testchi2(tabtest=tab,
                minsamp = minsamp,
                mintest = mintest)
  tab<-tab[order(when),]
  
  if (test==FALSE) {tab$index =tab$salience
  tab<-tab[tab$trial > minsamp,]
  mycol<-brewer.pal(7,"YlOrRd")
  } 
  else {tab$index=tab$p.value
  tab<-tab[tab$trial*tab$null.value>mintest,]
  mycol<-brewer.pal(7,"RdYlBu")
  mycol[4]<-"lightyellow"
  }
  
  
  p <- plot_ly(tab,
               x = ~as.character(when),
               y = ~estimate*100,
               color= ~index,
               colors= mycol,
     #          hoverinfo = "text",
               hovertemplate = ~paste('Time: ',when,
                             '<br /> Total news  : ', round(trial,0),
                             '<br /> Topic news : ', round(success,0),
                             '<br /> % observed  : ', round(estimate*100,2),'%',
                             '<br /> % estimated : ', round(null.value*100,2),'%',
                             '<br /> Salience : ', round(salience,2),  
                             '<br /> p.value : ', round(p.value,4)),
               type = "bar")  %>%
    layout(title = title,
           yaxis = list(title = "% news"),
           barmode = 'stack')
  
  output<-list("table" = tab, "plotly" =p)
  
  return(output)
  
}

Applicaton n°1 : Covid Topic

An example of computation of the share of a non spatial topic (Covid) in the full sample of news by week for one media in 2020-2021

res <- hc_week %>% filter(who=="DEU_suddeu") %>%
                   filter(when >= as.Date("2020-01-01"), when <=as.Date("2021-12-31")) %>%
when.what(what = "what",
     title = "Share of Covid-19 topic in news published by Süddeutsche Zeitung (2020-21)",
     test=TRUE)

head(res$table)
FALSE          when trial success null.value estimate   salience  chi2 p.value  index
FALSE 1: 2020-01-06   903       3     0.0858  0.00332 0.03869464 77.26  1.0000 1.0000
FALSE 2: 2020-01-13   924       2     0.0858  0.00216 0.02517483 81.34  1.0000 1.0000
FALSE 3: 2020-01-20  1027      33     0.0858  0.03213 0.37447552 37.03  1.0000 1.0000
FALSE 4: 2020-01-27   973      53     0.0858  0.05447 0.63484848 11.78  0.9997 0.9997
FALSE 5: 2020-02-03   906      38     0.0858  0.04194 0.48881119 21.66  1.0000 1.0000
FALSE 6: 2020-02-10   939      32     0.0858  0.03408 0.39720280 31.37  1.0000 1.0000
res$plotly

Application n°2 : State subtopic

Example of analysis of the share of news about Ukraine among news mentionning one country, by week, for Le Figaro in 2022

res <-hc_week %>% filter(states != "_no_") %>%  
                   filter(who=="FRA_figaro") %>%
#                   filter(when >= as.Date("2022-01-01")) %>%
when.what(what = "states",
     subtop ="UKR",
     title = "Share of Ukraine in international news published by Le Figaro ",
     test=TRUE)
head(res$table)
FALSE          when trial success null.value estimate   salience  chi2 p.value
FALSE 1: 2013-04-08   532       0      0.024  0.00000 0.00000000 12.08 0.99974
FALSE 2: 2013-04-15   705       1      0.024  0.00142 0.05916667 14.40 0.99993
FALSE 3: 2013-04-22   854       0      0.024  0.00000 0.00000000 19.99 1.00000
FALSE 4: 2013-04-29   678       2      0.024  0.00295 0.12291667 11.94 0.99973
FALSE 5: 2013-05-06   736       0      0.024  0.00000 0.00000000 17.09 0.99998
FALSE 6: 2013-05-13   745       0      0.024  0.00000 0.00000000 17.31 0.99998
FALSE      index
FALSE 1: 0.99974
FALSE 2: 0.99993
FALSE 3: 1.00000
FALSE 4: 0.99973
FALSE 5: 0.99998
FALSE 6: 0.99998
res$plotly

Application n°3 : Macroregion subtopic

Example of analysis of the share of news about European news among news mentioning one macroregion, by quarter, for Dunya during the whole period

res <-hc_month %>% filter(regions != "_no_") %>%  filter(who=="TUR_dunya") %>%
when.what(what = "regions",
     subtop ="OR_EU",
     title = "Share of EU in macroregional news published by Dunya (2013-2023)",
     test=TRUE)
head(res$table)
FALSE          when trial success null.value estimate  salience  chi2 p.value   index
FALSE 1: 2013-06-01    76      23      0.249  0.30263 1.2153815  0.90 0.17142 0.17142
FALSE 2: 2013-07-01    44      11      0.249  0.25000 1.0040161  0.00 0.50000 0.50000
FALSE 3: 2013-08-01    40       6      0.249  0.15000 0.6024096  1.60 0.89708 0.89708
FALSE 4: 2013-09-01    37       7      0.249  0.18919 0.7597992  0.42 0.74255 0.74255
FALSE 5: 2013-10-01    83      33      0.249  0.39759 1.5967470  9.02 0.00133 0.00133
FALSE 6: 2013-11-01   132      50      0.249  0.37879 1.5212450 11.21 0.00041 0.00041
res$plotly

Where.What

function

#### ---------------- where.what ----------------
#' @title  visualize spatialization of the topic 
#' @name where.what
#' @description create a table of variation of the topic by media
#' @param hc an hypercube prepared as data.table
#' @param test : visualize test (TRUE) or salience (FALSE)
#' @param minsamp : Threshold of sample size requested for salience computation
#' @param mintest sample size of estimate for chi-square test (default = 5)
#' @param map a map with coordinates in lat-long
#' @param proj a projection accepted by plotly
#' @param title Title of the graphic


where.what <- function (hc = hypercube,
                        what = "what",
                        where = "where",
                        subtop = NA,
                        test = FALSE,
                        minsamp = 20,
                        mintest = 5,
                        map = world_ctr,
                        proj = 'azimuthal equal area',
                        title = "Where said What ?")
{
 
  tab<-hc
  tab$what<-tab[[what]]
  tab$where<-tab[[where]]
if (is.na(subtop)){tab$what <-tab$what !="_no_"}else {tab$what <- tab$what == subtop}
#  {tab$what <-tab$what !="_no_"}
  
  tab<-tab[,list(trial = round(sum(news),0),success=round(sum(news*what),0)),by = list(where)]
  ref <-round(sum(tab$success)/sum(tab$trial),4)
  tab$null.value<-ref
  
  tab<-testchi2(tabtest=tab,
                minsamp = minsamp,
                mintest = mintest)
  
  
  
  tab<-tab[order(-chi2),]
  
  
  
  if (test==FALSE) {tab$index =tab$salience
  tab<-tab[tab$trial > minsamp,]
  mycol<-brewer.pal(7,"YlOrRd")
  } else {tab$index=tab$p.value
  tab<-tab[tab$trial*tab$null.value>mintest,]
  mycol<-brewer.pal(7,"RdYlBu")
  mycol[4]<-"lightyellow"
  }
  
  
  map<-merge(map,tab,all.x=T,all.y=F,by.x="ISO3",by.y="where")
  
  
  
  #map2<-map[is.na(map$pct)==F,]
  #map2<-st_centroid(map2)
  #map2<-st_drop_geometry(map2)
  
  
  g <- list(showframe = TRUE,
            framecolor= toRGB("gray20"),
            coastlinecolor = toRGB("gray20"),
            showland = TRUE,
            landcolor = toRGB("gray50"),
            showcountries = TRUE,
            countrycolor = toRGB("white"),
            countrywidth = 0.2,
            projection = list(type = proj))
  
  
  
  p<- plot_geo(map)%>%
    add_markers(x = ~lon,
                y = ~lat,
                sizes = c(0, 250),
                size = ~success,
                #             color= ~signif,
                color = ~index,
                colors= mycol,
#                hoverinfo = "text",
                hovertemplate = ~paste('Location: ',NAME,
                              '<br /> Total news  : ', round(trial,0),
                              '<br /> Topic news : ', round(success,0),
                              '<br /> % observed  : ', round(estimate*100,2),'%',
                              '<br /> % estimated : ', round(null.value*100,2),'%',
                              '<br /> Salience : ', round(salience,2),  
                              '<br /> p.value : ', round(p.value,4))) %>%
    
    layout(geo = g,
           title = title)
  
  
  
  output<-list("table" = tab, "plotly" =p)
  
  return(output)
  
}

Applicaton n°1 : Covid Topic

An example of computation of the share of a non spatial topic (Covid) in the full sample of news by week for one media.

world_ctr<-readRDS("map/world_ctr_4326.Rdata")
res <- hc_week %>% filter(who=="DEU_suddeu") %>%
                  filter(states != "DEU") %>%
                    filter(states != "_no_") %>%
                   filter(when >= as.Date("2020-01-01"), when <=as.Date("2021-12-31")) %>%
where.what(what = "what",
           where ="states",
     title = "Share of Covid-19 topic in foreign news published by Süddeutsche Zeitung in 2020-2021",
     minsamp = 5,
     mintest = 2,
     test=TRUE)

#res$table
res$plotly

Application n°2 : National subtopic

Impossible to use state as subtopic in this case

Application n°3 : Regional subtopic

Example of analysis of the share of news about Africa in news associated to one country

res <-hc_quarter %>% filter(regions != "_no_") %>% 
             filter(who=="TUR_dunya") %>%
             filter(states!="TUR") %>%
where.what(what = "regions",
           subtop = "OR_EU",
           where = "states",
           title = "Share of EU in macroregional news published by Dunya (2013-2023)", 
            test=TRUE,
           mintest=1,
           minsamp=5)
head(res$table)
FALSE    where trial success null.value estimate  salience   chi2 p.value index
FALSE 1:   GBR   191     120     0.2465  0.62827 2.5487627 147.83       0     0
FALSE 2:   BEL   166      93     0.2465  0.56024 2.2727789  86.29       0     0
FALSE 3:   RUS   660     246     0.2465  0.37273 1.5120892  55.94       0     0
FALSE 4:  _no_ 16377    3657     0.2465  0.22330 0.9058824  47.33       1     1
FALSE 5:   IRL    36      26     0.2465  0.72222 2.9298986  41.34       0     0
FALSE 6:   IRN   123      56     0.2465  0.45528 1.8469777  27.75       0     0
res$plotly

when.who.what

function

#### ---------------- when.who.what ----------------
#' @title  visualize variation of the topic by media through time
#' @name when.who.what
#' @description create a table of variation of the topic by media through time
#' @param hc an hypercube prepared as data.table
#' @param test : visualize test (TRUE) or salience (FALSE)
#' @param minsamp : Threshold of sample size requested for salience computation
#' @param mintest sample size of estimate for chi-square test (default = 5)
#' @param title Title of the graphic


when.who.what <- function (hc = hypercube,
                           what = "what",
                           subtop = NA,
                           test = FALSE,
                           minsamp = 20,
                           mintest = 5,
                           title = "What by Whom and When ?")
{
  
  tab<-hc
  tab$what<-tab[[what]]
if (is.na(subtop)){tab$what <-tab$what !="_no_"}else {tab$what <- tab$what == subtop}
#  {tab$what <-tab$what !="_no_"}
  tab<-tab[is.na(when)==F,]
  
  
  
  tab<-tab[,list(trial = sum(news),success=round(sum(news*what),0)),by = list(when,who)]
  ref<-tab[,list(null.value = round(sum(success)/sum(trial),4)), by = list(who)]
  tab<-merge(tab,ref,by="who")
  
  tab<-testchi2(tabtest=tab,
                minsamp = minsamp,
                mintest = mintest)
  
  
  if (test==FALSE) {tab$index =tab$salience
  tab<-tab[tab$trial > minsamp,]
  mycol<-brewer.pal(7,"YlOrRd")
  } 
  else {tab$index=tab$p.value
  tab<-tab[tab$trial*tab$null.value>mintest,]
  mycol<-brewer.pal(7,"RdYlBu")
  mycol[4]<-"lightyellow"
  }
  
  
  
  p <- plot_ly(tab,
               x = ~when,
               y = ~who,
               z= ~index,
               sizes = c(0, 250),
               size = ~success,
               colors= mycol,
               hovertext = ~paste( 'Total news  : ', round(trial,0),
                             '<br /> Topic news : ', round(success,0),
                             '<br /> % observed  : ', round(estimate*100,2),'%',
                             '<br /> % estimated : ', round(null.value*100,2),'%',
                             '<br /> Salience : ', round(salience,2),  
                             '<br /> p.value : ', round(p.value,4)),
               #  name = ~tags,
               type = "heatmap")  %>%

    layout(title = title,
           yaxis = list(title = "media"),
           xaxis = list(title = "time"))
  p
  
  
  
  output<-list("table" = tab, "plotly" =p)
  
  return(output)
  
}

Applicaton n°1 : Covid Topic

An example of computation of the share of a non spatial topic (Covid) in the full sample of news by week for one media.

res <- hc_week %>% filter(when >= as.Date("2019-01-01"), when <=as.Date("2022-12-31")) %>%
when.who.what(what = "what",
     title = "Share of Covid-19 topic in news published by newspapers (2019-2022)",
     test=TRUE)

head(res$table)
FALSE           who       when trial success null.value estimate  salience  chi2
FALSE 1: DEU_suddeu 2021-09-27  1905      55     0.0494  0.02887 0.5844130 16.66
FALSE 2: DEU_suddeu 2021-10-04  3764     159     0.0494  0.04224 0.8550607  3.96
FALSE 3: DEU_suddeu 2021-10-11  3558     129     0.0494  0.03626 0.7340081 12.81
FALSE 4: DEU_suddeu 2021-10-18  3552     135     0.0494  0.03801 0.7694332  9.58
FALSE 5: DEU_suddeu 2021-10-25  3130     121     0.0494  0.03866 0.7825911  7.46
FALSE 6: DEU_suddeu 2021-11-01  2711     150     0.0494  0.05533 1.1200405  1.91
FALSE    p.value   index
FALSE 1: 0.99998 0.99998
FALSE 2: 0.97664 0.97664
FALSE 3: 0.99983 0.99983
FALSE 4: 0.99902 0.99902
FALSE 5: 0.99685 0.99685
FALSE 6: 0.08371 0.08371
res$plotly

Applicaton n°2 : Ukraine in international news (by week)

How many news about Ukraine in international news (i.e. news mentioning at least one country) ?

res <-hc_month %>% filter(states != "_no_") %>%  
                   filter(states != substr(who,1,3)) %>%
when.who.what(what = "states",
              subtop="UKR",
     title = "Share of Ukraine in international news (2013-2023)",
     minsamp = 5,
     mintest = 1,
     test=TRUE)
head(res$table)
FALSE           who       when     trial success null.value estimate   salience
FALSE 1: DEU_suddeu 2021-10-01  753.8333       4     0.0558  0.00531 0.09516129
FALSE 2: DEU_suddeu 2021-11-01  615.2167      10     0.0558  0.01625 0.29121864
FALSE 3: DEU_suddeu 2021-12-01  634.1389      30     0.0558  0.04731 0.84784946
FALSE 4: DEU_suddeu 2022-01-01  682.5833      79     0.0558  0.11574 2.07419355
FALSE 5: DEU_suddeu 2022-02-01  915.1833     233     0.0558  0.25459 4.56254480
FALSE 6: DEU_suddeu 2022-03-01 1668.8167     916     0.0558  0.54889 9.83673835
FALSE       chi2 p.value   index
FALSE 1:   35.53 1.00000 1.00000
FALSE 2:   17.52 0.99999 0.99999
FALSE 3:    0.71 0.80098 0.80098
FALSE 4:   45.41 0.00000 0.00000
FALSE 5:  682.69 0.00000 0.00000
FALSE 6: 7691.98 0.00000 0.00000
res$plotly

Applicaton n°3 : EU in macroregional news (by quarter)

How many news about EU in macroregional news (i.e. news mentioning at least one macroregion) ?

res <- hc_month %>% filter(regions !="_no_") %>%
when.who.what(what = "regions", subtop="OR_EU",
     title = "Share of EU in macroregional news",
     minsamp = 5,
     mintest = 2,
     test=TRUE)
head(res)
FALSE $table
FALSE             who       when trial success null.value estimate  salience  chi2
FALSE   1: DEU_suddeu 2021-10-01   195     102     0.4749  0.52308 1.1014529  1.63
FALSE   2: DEU_suddeu 2021-11-01   193     100     0.4749  0.51813 1.0910297  1.28
FALSE   3: DEU_suddeu 2021-12-01   158      71     0.4749  0.44937 0.9462413  0.32
FALSE   4: DEU_suddeu 2022-01-01   177      82     0.4749  0.46328 0.9755317  0.05
FALSE   5: DEU_suddeu 2022-02-01   217      89     0.4749  0.41014 0.8636344  3.39
FALSE  ---                                                                        
FALSE 467:  TUR_dunya 2022-11-01   197      47     0.2490  0.23858 0.9581526  0.07
FALSE 468:  TUR_dunya 2022-12-01   507     176     0.2490  0.34714 1.3941365 25.59
FALSE 469:  TUR_dunya 2023-01-01   484      75     0.2490  0.15496 0.6223293 22.39
FALSE 470:  TUR_dunya 2023-02-01   216      54     0.2490  0.25000 1.0040161  0.00
FALSE 471:  TUR_dunya 2023-03-01   249      46     0.2490  0.18474 0.7419277  5.16
FALSE      p.value   index
FALSE   1: 0.10107 0.10107
FALSE   2: 0.12909 0.12909
FALSE   3: 0.71330 0.71330
FALSE   4: 0.59266 0.59266
FALSE   5: 0.96729 0.96729
FALSE  ---                
FALSE 467: 0.60097 0.60097
FALSE 468: 0.00000 0.00000
FALSE 469: 1.00000 1.00000
FALSE 470: 0.50000 0.50000
FALSE 471: 0.98845 0.98845
FALSE 
FALSE $plotly
res$plotly

Applicaton n°3bis : NATO in macroregional news (by year)

How many news about EU in macroregional news (i.e. news mentioning at least one macroregion) ?

res <- hc_year %>% filter(regions !="_no_") %>%
when.who.what(what = "regions", subtop="OR_NATO",
     title = "Share of NATO in macroregional news",
     minsamp = 5,
     mintest = 2,
     test=TRUE)
head(res)
FALSE $table
FALSE            who       when trial success null.value estimate  salience   chi2
FALSE  1: DEU_suddeu 2021-01-01  1294      69     0.0490  0.05332 1.0881633   0.43
FALSE  2: DEU_suddeu 2022-01-01  1456     180     0.0490  0.12363 2.5230612 172.41
FALSE  3: DEU_suddeu 2020-01-01  1117      31     0.0490  0.02775 0.5663265  10.37
FALSE  4: DEU_suddeu 2013-01-01  1345      32     0.0490  0.02379 0.4855102  17.80
FALSE  5: DEU_suddeu 2014-01-01  1775      98     0.0490  0.05521 1.1267347   1.34
FALSE  6: DEU_suddeu 2015-01-01  3048     133     0.0490  0.04364 0.8906122   1.77
FALSE  7: DEU_suddeu 2016-01-01  2361      93     0.0490  0.03939 0.8038776   4.48
FALSE  8: DEU_suddeu 2017-01-01  2176     106     0.0490  0.04871 0.9940816   0.00
FALSE  9: DEU_suddeu 2018-01-01  2547     106     0.0490  0.04162 0.8493878   2.82
FALSE 10: DEU_suddeu 2019-01-01  1690      73     0.0490  0.04320 0.8816327   1.10
FALSE 11: FRA_figaro 2021-01-01  1695      40     0.0452  0.02360 0.5221239  17.83
FALSE 12: FRA_figaro 2022-01-01  1939     226     0.0452  0.11655 2.5785398 227.11
FALSE 13: FRA_figaro 2020-01-01  2271      56     0.0452  0.02466 0.5455752  21.73
FALSE 14: FRA_figaro 2013-01-01  2442      63     0.0452  0.02580 0.5707965  20.85
FALSE 15: FRA_figaro 2014-01-01  3733     283     0.0452  0.07581 1.6772124  80.34
FALSE 16: FRA_figaro 2015-01-01  4215     155     0.0452  0.03677 0.8134956   6.74
FALSE 17: FRA_figaro 2016-01-01  3938     116     0.0452  0.02946 0.6517699  22.25
FALSE 18: FRA_figaro 2017-01-01  3675     184     0.0452  0.05007 1.1077434   1.91
FALSE 19: FRA_figaro 2018-01-01  2902      98     0.0452  0.03377 0.7471239   8.52
FALSE 20: FRA_figaro 2019-01-01  2684      96     0.0452  0.03577 0.7913717   5.32
FALSE 21: FRA_figaro 2023-01-01   299      31     0.0452  0.10368 2.2938053  22.36
FALSE 22: TUN_afrman 2013-01-01   226       0     0.0209  0.00000 0.0000000   3.86
FALSE 23: TUN_afrman 2014-01-01   454       4     0.0209  0.00881 0.4215311   2.68
FALSE 24: TUN_afrman 2015-01-01   529      27     0.0209  0.05104 2.4421053  22.03
FALSE 25: TUN_afrman 2016-01-01   908      16     0.0209  0.01762 0.8430622   0.33
FALSE 26: TUN_afrman 2017-01-01   718      10     0.0209  0.01393 0.6665072   1.38
FALSE 27: TUN_afrman 2018-01-01   645      14     0.0209  0.02171 1.0387560   0.00
FALSE 28: TUN_afrman 2019-01-01   530       2     0.0209  0.00377 0.1803828   6.78
FALSE 29: TUN_afrman 2020-01-01   561       4     0.0209  0.00713 0.3411483   4.55
FALSE 30: TUN_afrman 2021-01-01   852      10     0.0209  0.01174 0.5617225   3.06
FALSE 31: TUN_afrman 2022-01-01  1292      37     0.0209  0.02864 1.3703349   3.41
FALSE 32: TUN_afrman 2023-01-01   445      26     0.0209  0.05843 2.7956938  28.82
FALSE 33:  TUR_dunya 2019-01-01  3428     141     0.0406  0.04113 1.0130542   0.01
FALSE 34:  TUR_dunya 2020-01-01  5006      57     0.0406  0.01139 0.2805419 108.93
FALSE 35:  TUR_dunya 2021-01-01  4868     112     0.0406  0.02301 0.5667488  38.23
FALSE 36:  TUR_dunya 2022-01-01  4453     262     0.0406  0.05884 1.4492611  37.55
FALSE 37:  TUR_dunya 2013-01-01   547      21     0.0406  0.03839 0.9455665   0.02
FALSE 38:  TUR_dunya 2014-01-01  1188      80     0.0406  0.06734 1.6586207  21.13
FALSE 39:  TUR_dunya 2015-01-01  1046      50     0.0406  0.04780 1.1773399   1.21
FALSE 40:  TUR_dunya 2016-01-01  1197      58     0.0406  0.04845 1.1933498   1.70
FALSE 41:  TUR_dunya 2017-01-01  1495      94     0.0406  0.06288 1.5487685  18.48
FALSE 42:  TUR_dunya 2018-01-01  1036      81     0.0406  0.07819 1.9258621  36.61
FALSE 43:  TUR_dunya 2023-01-01   949      68     0.0406  0.07165 1.7647783  22.71
FALSE            who       when trial success null.value estimate  salience   chi2
FALSE     p.value   index
FALSE  1: 0.25591 0.25591
FALSE  2: 0.00000 0.00000
FALSE  3: 0.99936 0.99936
FALSE  4: 0.99999 0.99999
FALSE  5: 0.12358 0.12358
FALSE  6: 0.90826 0.90826
FALSE  7: 0.98280 0.98280
FALSE  8: 0.50491 0.50491
FALSE  9: 0.95353 0.95353
FALSE 10: 0.85293 0.85293
FALSE 11: 0.99999 0.99999
FALSE 12: 0.00000 0.00000
FALSE 13: 1.00000 1.00000
FALSE 14: 1.00000 1.00000
FALSE 15: 0.00000 0.00000
FALSE 16: 0.99529 0.99529
FALSE 17: 1.00000 1.00000
FALSE 18: 0.08366 0.08366
FALSE 19: 0.99825 0.99825
FALSE 20: 0.98944 0.98944
FALSE 21: 0.00000 0.00000
FALSE 22: 0.97523 0.97523
FALSE 23: 0.94915 0.94915
FALSE 24: 0.00000 0.00000
FALSE 25: 0.71725 0.71725
FALSE 26: 0.88012 0.88012
FALSE 27: 0.49786 0.49786
FALSE 28: 0.99540 0.99540
FALSE 29: 0.98351 0.98351
FALSE 30: 0.95993 0.95993
FALSE 31: 0.03237 0.03237
FALSE 32: 0.00000 0.00000
FALSE 33: 0.45442 0.45442
FALSE 34: 1.00000 1.00000
FALSE 35: 1.00000 1.00000
FALSE 36: 0.00000 0.00000
FALSE 37: 0.56097 0.56097
FALSE 38: 0.00000 0.00000
FALSE 39: 0.13529 0.13529
FALSE 40: 0.09617 0.09617
FALSE 41: 0.00001 0.00001
FALSE 42: 0.00000 0.00000
FALSE 43: 0.00000 0.00000
FALSE     p.value   index
FALSE 
FALSE $plotly
res$plotly